<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>

<%@ include file="../common/header.jsp"%>
<style>
    .layui-form{
        margin-top: -10px;
    }

    .layui-colla-item, .layui-colla-content {
    }
</style>

<script type="application/javascript" src="/static/webjars/layui/layui.js"></script>

<div id="saper-container">
    <div id="saper-hd"></div>
    <div id="saper-bd">
        <div class="subfiled clearfix">
            <h2>重点组织管理</h2>
        </div>
    </div>
</div>

<div id="container" >
    <div id="bd" style="width: 98%;height:100%;margin: 0 auto">
        <div id="test" >
            <form class="layui-form" action="" style="margin-top: -10px;" lay-filter="Proprietor">
                <div class="layui-colla-content layui-show">
                    <table class="layui-table">
                        <div>
                            <input type="text" id="id" name="id" style="display: none">
                        </div>

                        <tr>
                            <td width="150px">重点组织名</td>
                            <td>
                                <div class="layui-inline">
                                    <input type="text" name="organize_name" id="organize_name" autocomplete="off" placeholder="请输入重点组织名" class="layui-input">
                                </div>
                            </td>
                        </tr>


                        <tr>
                            <td>详细地址</td>
                            <td>
                                <div class="layui-inline">
                                    <input type="text" name="organize_area" id="organize_area" autocomplete="off" placeholder="请输入详细地址" class="layui-input">
                                </div>
                            </td>
                        </tr>

                        <tr>
                            <td>负责人</td>
                            <td>
                                <div class="layui-inline">
                                    <input type="text" name="manager" id="manager" autocomplete="off" placeholder="请输入组织负责人名"  class="layui-input">
                                </div>
                            </td>
                        </tr>

                        <tr>
                            <td>联系电话</td>
                            <td>
                                <div class="layui-inline">
                                    <input type="text" name="tellphone" id="tellphone" autocomplete="off" placeholder="请输入联系电话"  class="layui-input">
                                </div>
                            </td>
                        </tr>

                        <tr>
                            <td>组织信息</td>
                            <td>
                                <textarea placeholder="请输入信息" name="organize_info" id="organize_info" class="layui-textarea"></textarea>
                            </td>
                        </tr>

                        <tr>
                            <td>关注原因</td>
                            <td>
                                <textarea placeholder="请输入内容" name="reason" id="reason" class="layui-textarea"></textarea>
                            </td>
                        </tr>

                        <tr>
                            <td>关注日期</td>
                            <td>
                                <div class="layui-inline">
                                    <input type="text" id="born" name="focus_time" autocomplete="off" placeholder="yyyy-MM-dd" class="layui-input">
                                </div>
                            </td>
                        </tr>

                        <tr>
                            <td>最新消息</td>
                            <td>
                                <textarea placeholder="请输入内容" name="news" id="news" class="layui-textarea"></textarea>
                            </td>
                        </tr>


                    </table>
                </div>

                <div class="layui-form-item" style="text-align: center">
                    <div class="layui-input-block">
                        <button class="layui-btn" lay-submit lay-filter="keyorganization-form" id="submit">立即提交</button>
                        <span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>
                        <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                    </div>
                </div>
            </form>
        </div>
    </div>
</div>

<%@ include file="../common/footer.jsp"%>

<script type="text/javascript" src="/static/js/jquery.min.js"></script>

<script>

    layui.use('form', function() {
        $("div").removeClass("iselect-wrapper");
        //时间戳
        var nowtimestamp = (new Date()).getTime();
        var layer = layui.layer;
        var form = layui.form;
        var laydate = layui.laydate;
        var upload = layui.upload;

        laydate.render({
            elem: '#born' //指定元素
        });

        $.fn.serializeObject = function () {
            var o = {};
            var a = this.serializeArray();
            $.each(a, function () {
                if (o[this.name]) {
                    if (!o[this.name].push) {
                        o[this.name] = [o[this.name]];
                    }
                    o[this.name].push(this.value || '');
                } else {
                    o[this.name] = this.value || '';
                }
            });
            return o;
        };


        var dddd = new Date();
        console.log(dddd.getFullYear() + "-" + dddd.getMonth() + "-" + dddd.getDay());//获取系统当前时间

        form.on('submit(keyorganization-form)', function (data) {  //保存选项

            data.field.time = dddd.getFullYear() + "-" + dddd.getMonth() + 1 + "-" + dddd.getDate();
            data.field.time = dddd.toLocaleString();

            layer.msg("提交中");

            data.field.organize_area = $("#organize_area").val();
            data.field.reason = $("#reason").val();


            console.log(data.field + ":reason= " + $("#reason").val());

            $.ajax({
                url: "/ajax/save/keyorganization",
                type: "POST",
                contentType: 'application/json;charset=utf-8',
                //设置请求头信息
                dataType: "json",
                data: JSON.stringify(data.field),
                success: function (data) {
                    layer.msg(data.code);
                    nowtimestamp = (new Date()).getTime();
                    form.render();
                },
                error: function (res) {
                    layer.msg(res);
                }
            });
            return false; //阻止表单跳转。如果需要表单跳转，去掉这段即可。
        });

        function timestampToTime(timestamp) {
            var date = new Date(timestamp * 1000);//时间戳为10位需*1000，时间戳为13位的话不需乘1000
            Y = date.getFullYear() + '-';
            M = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '-';
            D = date.getDate() + ' ';
            h = date.getHours() + ':';
            m = date.getMinutes() + ':';
            s = date.getSeconds();
            return Y + M + D + h + m + s;
        }

    });

</script>